{% extends "mturk/base_app.html" %}
{% load switchcase %}

{% block subtitle %}Session dashboard: {{session.code}} | {% endblock %}

{% block subbranding %}Session dashboard: {{session.code}} | {% endblock %}

{% block extrahead %}
<script src="/code/js/prototype.js" language="javascript"></script>

<script>
var run_search=function(session_code,search_inp)
{
    loc="/mt/good_results_w_filter/"+session_code+"/p1/"+search_inp+"/";
    window.location=loc;
}
var run_put_with_priority=function(session_code,priority_inp)
{
    loc="/mt/queue/put/session/"+session_code+"/"+priority_inp+"/";
    window.location=loc;
}
</script>
{% endblock %}



{% block content %}


<table><tr><td>
Session {{session.code}} [{% if session.sandbox %}
SANDBOX
{% else %}
PRODUCTION
{% endif %}].<br/>

HITs {{stats.hits.count}} (limit {{session.HITlimit}}). <b>Idle {{stats.hits.num_idle}}, Active {{stats.hits.num_active}}, Finalized {{stats.hits.num_finalized}}</b><br/>
Submissions: Total {{session.submittedtask_set.count}}. Approved {{stats.submissions.approved}}. Rejected {{stats.submissions.rejected}}. <b>Open {{stats.submissions.open}}.</b><br/>

<hr/>
<h2>Common actions</h2>
<ul>
<li><a href="/mt/grading/{{session.code}}/">Grading paged</a></li>
<li><a href="/mt/process_graded_submissions/{{session.code}}/">Process graded submissions</a></li>
<li><a href="#downloads">Downloads</a></li>
</ul>

<hr/>

<h2>Grading</h2>

Local:<br/>
<ul>
<li><a href="/mt/grading/{{session.code}}/">Grading paged</a></li>
<li><a href="/mt/result_stats/{{session.code}}/by_worker/">Grading by worker</a></li>
<li><a href="/mt/grading/thumbnails_random/{{session.code}}/">Random grading in thumbnails</a></li>
</ul>

<hr/>
Mech Turk:<br/>
<ul>
<li>
<a href="/mt/grading/submit/session/{{session.code}}/{{session.code}}-grading/">Submit all for grading to session1</a> ( <a href="/mt/dashboard/session/{{session.code}}-grading/">dashboard</a> )</li>

<li><a href="/mt/grading/submit/session/{{session.code}}/{{session.code}}-grading-2/">Submit all for grading to session2</a> ( <a href="/mt/dashboard/session/{{session.code}}-grading-2/">dashboard</a> )</li>

</ul>
<hr/>


<h2>Tasks</h2>
<ul>
<li>
{% if session.sandbox %}
<a href="https://workersandbox.mturk.com/mturk/preview?groupId={{session.hit_type}}">Browse tasks on MechTurk (sandbox)</a>
{% else %}
<a href="https://www.mturk.com/mturk/preview?groupId={{session.hit_type}}">Browse tasks on MechTurk (production)</a>
{% endif %}
</li>
<li>
<a href="/mt/expire_session_hits/{{session.code}}/">Expire all <b>active</b> from this session</a></li>
<li>
<a href="/mt/expire_session_hits_by_type/{{session.code}}/">Expire <b>all</b> hits with the same <b>task</b> as this session</a></li>
</ul>
<hr/>

{% if session.use_task_priority %}
<h2>Queue</h2>
<ul>
<li> Priority: <input id="new_priority" name="new_priority" value="50">. <a href="#" onclick="run_put_with_priority('{{session.code}}',$F('new_priority'));return false;">Put session on the queue</a>.</li>
<li><a href="/mt/queue/remove/session/{{session.code}}/">Remove the session from the queue.</a></li>
</ul>
{% endif %}




<h2>Approval</h2>
<ul>
<li><a href="/mt/approve_good_results/{{session.code}}/" onclick="if(confirm('Do you want to approve good results and results with errors?')){return true;}else{ return false;}">Approve good results and results with errors</a></li>
<li><a href="/mt/reject_poor_results/{{session.code}}/" onclick="if(confirm('Do you want to reject bad results?')){return true;}else{ return false;}">Reject bad results</a></li>

<li><a href="/mt/approve_all_results/{{session.code}}/"onclick="if(confirm('Do you want to approve all open results?')){return true;}else{ return false;}">Approve all open results (regardless if they were graded)</a></li>

<li>
<a href="/mt/resubmit_bad_results/{{session.code}}/"
onclick="if(confirm('Do you want to resubmit the HITs that don\'t have good results yet?')){return true;}else{ return false;}">
<b>Resubmit</b> the HITs that don't have a good result yet.</a></li>
</ul>
<hr/>
<h2>Results</h2>
Browse:<br/>
<ul>
<li><a href="/mt/results/{{session.code}}/">All results</a><br/></li>
<li><a href="/mt/good_results/{{session.code}}/">Good results</a><br/></li>
<li> Filter by: <input id="search_inp" name="search_inp"> <a href="#" onclick="run_search('{{session.code}}',$F('search_inp'));return false;">search</a>. Try image name or timestamp.
</ul>

<br/>
<a id="downloads">Download</a>:<br/>
<ul>
<li>
<code>
rosrun cv_mech_turk2 session_results.py --session={{session.code}}
</code></li>


{% switch session.task_def.type.name %}
    {% case "video_events" %} {% endcase %}
    {% case "gxml" %}
<li><a href="/mt/p/gxml/create_download/{{session.code}}/pack/">Create standard pack (images,xml,png masks).</a><br/>
<ul>
{% for fn in session.list_downloads.pack %}
<li><a href="/mt/download/{{session.code}}/pack/{{fn}}">{{fn}}</a></li>
{% endfor %}
</ul>
</li>

<li>
<a href="/mt/p/gxml/create_download/{{session.code}}/xml_masks/">Create xml+masks (no images).</a><br/>
<ul>
{% for fn in session.list_downloads.xml_and_masks %}
<li><a href="/mt/download/{{session.code}}/xml_and_masks/{{fn}}">{{fn}}</a></li>
{% endfor %}
</ul>
</li>
    {% endcase %}


    {% case "attributes" %}
<a href="/mt/p/attributes/create_download/{{session.code}}/raw_xml/">Create raw XML (work units, work submissions).</a><br/>
<ul>
{% for fn in session.list_downloads.raw_xml %}
<li><a href="/mt/download/{{session.code}}/raw_xml/{{fn}}">{{fn}}</a></li>
{% endfor %}
</ul>
    {% endcase %}
{% endswitch %}

</ul>


<hr/>
<h2>Upload</h2>
<ul>
{% switch session.task_def.type.name %}
    {% case "video_events" %} <a href="/mt/p/video_events/upload/{{session.code}}/video/">Single video</a> {% endcase %}
    {% case "gxml" %}
<li><a href="/mt/p/gxml/upload/{{session.code}}/image/">Single image</a></li>
<li><a href="/mt/p/gxml/upload/{{session.code}}/image_tgz/">Single folder with jpeg images</a>. (smth.tgz with my_folder/abc*.jpg)</li>
    {% endcase %}
    {% case "attributes" %}
<li><a href="/mt/project/submit_boxes_to_attributes/">From boxes sessions</a></li>
    {% endcase %}
{% endswitch %}
</ul>
<hr/>
<h2>Definitions</h2>
<ul>
  <li><a href="/admin/mturk/task/{{session.task_def.id}}/">Task definition</a></li>
  <li><a href="/admin/mturk/session/{{session.id}}/">Session definition</a></li>
  <li><a href="/admin/mturk/sessionexclusion/">Session exclusions</a></li>
  <li>Grading sessions: <a href="/mt/dashboard/session/{{session.code}}-grading/">(1)</a> , <a href="/mt/dashboard/session/{{session.code}}-grading-2/">(2)</a> </li>

</ul>
  

<h2>State statistics</h2>

<table>
<tr><th colspan="2">Work units:</th></tr>
<tr><th>State</th><th>Count</th></tr>
{% for rcd in stats.hits.counts_by_state %}
<tr><td>{{rcd.state_name}}</td><td>{{rcd.count}}</td></tr>
{% endfor %}
<tr><th colspan="2">Submissions:</th></tr>
<tr><th>State</th><th>Count</th></tr>
{% for rcd in stats.submissions.counts_by_state %}
<tr><td>{{rcd.state_name}}</td><td>{{rcd.count}}</td></tr>
{% endfor %}
</table>
<hr/>



<h2>Grade statistics</h2>

<ul>
<li>
Grade counts (contains multiple counts per submission):<br/>
<table>
<tr><td>Good :</td><td>{{stats.total_grades.num_good}}</td></tr>
<tr><td>With errors:</td><td> {{stats.total_grades.num_ok}}</td></tr>
<tr><td>Bad :</td><td>{{stats.total_grades.num_bad}}</td></tr>

<tr><th>Ungraded:</th><td> {{stats.total_grades.num_ungraded}}</td></tr>
<tr><th>Conflicts:</th><td> {{stats.conflicts.stats.num_conflicts}}</td></tr>
</table></li>

<li> Conflict distribution:<br/>
<table><tr><td> </td>
{% for c in stats.session_grades.conflict_distribution_tbl.columns %}
<td>{{c}}</td>
{% endfor %}
</tr>
{% for r in stats.session_grades.conflict_distribution_tbl.rows %}
<td>{{r.label}}</td>
{% for v in r.row %}
<td><a href="/mt/grading/conflict/show/{{session.code}}/{{v.i}}/{{v.j}}/">{{v.v}}</a></td>
{% endfor %}
</tr>

{% endfor %}
</table>
</li>
</ul>

<hr/>
</td><td>
<iframe src="http://www.google.com/friendconnect/discuss?scope=web&topic={{session.task_def.name}}%3A%20clarifications%3A(MechTurk)" style="width:250px;height:440px;" scrolling="no" allowtransparency="true" border="0" frameborder="0" ></iframe>
</td></tr></table>
{% endblock %}
